package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：陈九
 * @date ：Created in 2022年06月07日
 * @description ：
 * @version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/mobile/setmeal")
public class SetMealMobileController {
    @Autowired
    private SetMealService setMealService;
    @GetMapping("/getSetmeal")
    public Result findAll(){
        log.info("[查询所有套餐信息]");
        List<Setmeal> setMeals = setMealService.findAll();
        return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS,setMeals);
    }

    /**
     * 根据套餐id查询套餐所有信息
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result findById(Integer id){
        Setmeal setmeal= setMealService.findById(id);
        return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
    }

}
